﻿using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

namespace Metro.Kashikoi.ServiceContract.Storage
{
    /// <summary>
    /// Provides the abstract base class for Trigger.
    /// </summary>
    [DataContract(IsReference = true)]
    [KnownType(typeof(DoorTrigger))]
    [KnownType(typeof(AutoTrigger))]
    [KnownType(typeof(WeeklyTrigger))]
    [KnownType(typeof(DailyTrigger))]
    [Table("Tiggers")]
    public abstract class Trigger
    {
        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        /// <value>
        /// The id.
        /// </value>
        [DataMember]
        [Key]
        [Range(0, int.MaxValue)]
        [RangeValidator(0, RangeBoundaryType.Inclusive, int.MaxValue, RangeBoundaryType.Inclusive)]
        public int Id { get; set; }

        /// <summary>
        /// Gets or sets the inventory.
        /// </summary>
        /// <value>
        /// The inventory.
        /// </value>
        [DataMember]
        public Inventory Inventory { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="Trigger"/> is deleted.
        /// </summary>
        /// <value>
        ///   <c>true</c> if deleted; otherwise, <c>false</c>.
        /// </value>
        [DataMember]
        public bool Deleted { get; set; }

        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns>Newly cloned instance.</returns>
        public abstract Trigger Clone();
    }
}
